package pl.edu.agh.neuraleconomy.ui;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.widgets.TabFolder;

import pl.edu.agh.neuraleconomy.core.nn.NetworkStructure;
import pl.edu.agh.neuraleconomy.core.nn.SimpleNetwork;
import pl.edu.agh.neuraleconomy.core.simulation.SimulationEngine;
import pl.edu.agh.neuraleconomy.model.exchange.Company;
import pl.edu.agh.neuraleconomy.ui.component.ChartPanel;

public class Context {
	public static final String SIMULATION = "simulation";
	public static final String SHELL = "shell";
	public static final String CHART_PANEL = "chart_panel";
	public static final String TAB_FOLDER = "tab_folder";
	public static final String NETWORK_STRUCTURE = "network_structure";
	
	private static Map<String, Object> contextMap = new HashMap<String, Object>();
	private static Map<Company, SimpleNetwork> networkMap = new HashMap<Company, SimpleNetwork>();
	
	public static Object get(String key){
		return contextMap.get(key);
	}
	
	public static void put(String key, Object value){
		if(get(key) != null){
			contextMap.remove(key);
		}
		contextMap.put(key, value);
	}
	
	public static void putNetwork(Company company, SimpleNetwork network){
		if(networkMap.get(company)!=null){
			networkMap.remove(company);
		}
		networkMap.put(company, network);
	}
	
	public static SimpleNetwork getNetwork(Company company){
		return networkMap.get(company);
	}
	
	public static SimulationEngine getSimulation(){
		return (SimulationEngine) get(SIMULATION);
	}
	
	public static ChartPanel getChartPanel(){
		return (ChartPanel) get(CHART_PANEL);
	}
	
	public static TabFolder getTabFolder(){
		return (TabFolder) get(TAB_FOLDER);
	}
	
	public static NetworkStructure getNetworkStructure(){
		return (NetworkStructure) get(NETWORK_STRUCTURE);
	}
}
